package cn.itcast.xuesheng.dao.impl;

import cn.itcast.xuesheng.dao.CategoryDao;
import cn.itcast.xuesheng.domain.Category;
import cn.itcast.xuesheng.utils.JdbcUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository("categoryDao")
//假如想使用JdbcDaoSupport来让类继承
public class CateGoryDaoImpl implements CategoryDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public List<Category> findall(){
        String sql="SELECT * FROM category";
        return jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(Category.class));
    }
}
